package com.itheima.mvc;

import com.itheima.Interceptor.DemoInterceptor;
import com.itheima.Interceptor.TokenInterceptor;
import com.itheima.Interceptor.TokenInterceptor01;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.config.annotation.InterceptorRegistration;
import org.springframework.web.servlet.config.annotation.InterceptorRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;
@Component
public class WebConfig implements WebMvcConfigurer {

    // 自定义拦截对象
    @Autowired
    private TokenInterceptor01 tokenInterceptor01;

    @Override
    public void addInterceptors(InterceptorRegistry registry){
        // 注册自定义拦截器对象
        //addInterceptor方法用于向Web应用程序的拦截器链中注册一个自定义的拦截器对象
        registry.addInterceptor(tokenInterceptor01)
                .addPathPatterns("/**")
                .excludePathPatterns("/login");
        //设置拦截器拦截的请求路径（ /** 表示拦截所有请求）
    }



}
